<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

	<!-- This code written by : Willie Wheeler and John Wheeler -->
	<!-- For 'Spring In Practice' [Book written by Willie Wheeler and John Wheeler] -->

<c:set var="forum" value="${message.forum}"/>

<c:url var="stylesUrl" value="/styles.css"/>

<html>
	<head>
		<title>${message.subject}</title>
		<link rel="stylesheet" type="text/css" href="${stylesUrl}">
	</head>
	<body>
		<jsp:include page="header.jsp"/>
		<div id="body">
			<div>
				<a href="home.do">Home</a> &gt;
				<a href="forum.do?id=${forum.id}">${forum.name}</a> &gt;
				${message.subject}
			</div>
	
			<c:if test="${not message.visible}">
				<h1>[MESSAGE HAS BEEN BLOCKED]</h1>
			</c:if>
			
			<h1>${message.subject}</h1>
			
			<table>
				<tr>
					<td><b>Author:</b></td>
					<td>${message.author}</td>
				</tr>
				<tr>
					<td><b>Date:</b></td>
					<td><fmt:formatDate value="${message.date}"/></td>
				</tr>
			</table>
			
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
			
			<hr />
			<p>
				<a href="post.do?forumId=${forum.id}">Reply</a>
				
				<security:accesscontrollist domainObject="${message}" hasPermission="2,16">
					| <a href="#">Edit message</a>
				</security:accesscontrollist>
				
				<%-- Use security:accesscontrollist instead of security:authorize
				     since former can account for both the ROLE_ADMIN principal
				     and also ACEs (such as forum moderators who aren't ROLE_ADMIN
				     but who still have BasePermission.ADMINISTRATION --%>
				<security:accesscontrollist domainObject="${message}" hasPermission="16">
					<c:choose>
						<c:when test="${message.visible}">
							| <a href="#">Block message</a>
						</c:when>
						<c:otherwise>
							| <a href="#">Unblock message</a>
						</c:otherwise>
					</c:choose>
				</security:accesscontrollist>
			</p>
		</div>
	</body>
</html>
